home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Camelot / Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].zip / Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].adf / XLisp-Stat / Book / projection.lsp < prev    next >
Lisp/Scheme  |  1990-10-11  |  715b  |  29 lines

  1. ; book p.96
  2.  
  3. #|(defun make-projection (x)
  4.   (flet ((ip (x y) (sum (* x y))))
  5.     #'(lambda (y) (* x (/ (ip x y) (ip x x))))))
  6. |#
  7. #|
  8. (defun make-projection (x)
  9.   (labels ((ip (x y) (sum (* x y)))
  10.            (proj (y) (* x (/ (ip x y) (ip x x)))))
  11.     #'proj))
  12.  
  13. (def p (make-projection '(1 1 1 1)))
  14. |#
  15.  
  16. ; book p.172
  17.  
  18. (defun make-projection (cols)
  19.   (let* ((x (if (matrixp cols)
  20.                  cols
  21.                  (apply #'bind-columns cols)))
  22.          (svd (sv-decomp x))
  23.          (u (first svd))
  24.          (s-vals (second svd))
  25.          (basis (select (column-list u)
  26.                         (which (> s-vals 0.0))))
  27.          (u1 (apply #'bind-columns basis)))
  28.        #'(lambda (y) (matmult u1 (matmult y u1)))))
  29.